<template>
	<el-menu :default-openeds="['1']" default-active="/home/view" style="overflow-x: hidden; height: 100%;"
			 background-color=rgb(48,65,86)
			 text-color=#ccc active-text-color=#4db57a router>
		<div style="text-align:center;margin: 10px;">
			<img src="../assets/logo.png" style="width:20px;position:relative;top:5px;margin-right:5px"/>
			<b style="color:white">控制台</b>
		</div>
		<el-submenu v-for="(item,index) in menus" :index="index+''" :key="index">
			<template slot="title"><i :class="`${item.icon}`"></i>{{item.name}}</template>
			<el-menu-item v-for="(item1,index1) in item.children" :key="index1" :index="item1.component">{{item1.name}}</el-menu-item>
		</el-submenu>


		<!--                <el-submenu index="1">-->
		<!--                            <template slot="title">-->
		<!--                                <i class="el-icon-cpu">-->

		<!--                                </i>设备管理-->
		<!--                            </template>-->
		<!--                            <el-menu-item index="/home/view">设备概览</el-menu-item>-->
		<!--                            <el-menu-item index="/home/detail">设备详情</el-menu-item>-->
		<!--                        </el-submenu>-->


		<!--                        <el-submenu index="2">-->
		<!--                            <template slot="title">-->
		<!--                                <i class="el-icon-menu"></i>任务管理-->
		<!--                            </template>-->
		<!--                            <el-menu-item index="/home/route">航线编辑</el-menu-item>-->
		<!--                            <el-menu-item index="/home/task">航线管理</el-menu-item>-->
		<!--                        </el-submenu>-->
		<!--                        <el-submenu index="3">-->
		<!--                            <template slot="title">-->
		<!--                                <i class="el-icon-user"></i>服务管理-->
		<!--                            </template>-->
		<!--                            <el-menu-item index="/home/service">用户申请</el-menu-item>-->
		<!--                            <el-menu-item index="/home/logView">权限分配</el-menu-item>-->
		<!--                        </el-submenu>-->
		<!--                        <el-submenu index="4">-->
		<!--                            <template slot="title">-->
		<!--                                <i class="el-icon-camera"></i>数据管理-->
		<!--                            </template>-->
		<!--                            <el-menu-item index="/home/realtime">实时控制</el-menu-item>-->
		<!--                            <el-menu-item index="/home/replay">任务回放</el-menu-item>-->
		<!--                        </el-submenu>-->
		<!--                        <el-submenu index="5">-->
		<!--                            <template slot="title">-->
		<!--                                <i class="el-icon-setting"></i>系统管理-->
		<!--                            </template>-->
		<!--                            <el-menu-item index="/home/">用户管理</el-menu-item>-->
		<!--                        </el-submenu>-->
	</el-menu>
</template>

<script>

	import webSetInfo from "../server/webSetInfo";

	export default {
		//输出组件
		name: "Aside",
		admin: false,
		props: {
			admin: Boolean,
		},
		data() {
			return {
				menus: this.$store.state.userMenus,
			}
		},
		mounted() {
			this.getRouter();
		},
		methods: {
			async getRouter() {
				await this.$axios_token({
					url: `${webSetInfo.apiUrl}` + `/sys/getRouters`,
					data: {}
				}).then(res => {
					let data = res.data;
					if (data) {
						this.menus = data;
						this.$store.commit("setUserMenus", data);
					}
				})
			}
		}
	}
</script>

<style scoped>
</style>
